<template>
    <div>
        <el-pagination
            @size-change="handleSizeChange"
            @current-change="toClick($event, dataList.page.pageSize)"
            :page-sizes="[10, 20, 50, 100]"
            :current-page="dataList.page.pageNo"
            :page-size="dataList.page.pageSize"
            :layout="layout"
            :total="dataList.total">
        </el-pagination>
    </div>
</template>

<script>
export default {
    name: 'pages',
    props: {
        dataList: {
            list: [],
            page: {
                pageNo: 1,
                pageSize: 20
            },
            total: 0
        },
        toClick: {
            type: Function,
            default: () => {}
        },
        layout: {
            type: String,
            default: 'total, sizes, prev, pager, next, jumper'
        }
    },
    methods: {
        handleSizeChange(val) {
            let page = this.dataList.page;
            this.toClick(page.pageNo, val);
        }
    }
}
</script>
